package com.tedu.day07springmvc.controller;

import com.tedu.day07springmvc.pojo.dto.BmiDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BmiController {

    @RequestMapping("/userBmi")
    @ResponseBody
    public String userBmi(BmiDTO bmiDTO){
        double bmi =bmiDTO.getWeight()/(bmiDTO.getHeight()*bmiDTO.getHeight());
        System.out.println(bmiDTO+", 体重指数:"+bmi);
        if(bmi<18.5){
            return bmiDTO.getName()+",您好,您的体重指数为:"+bmi+",有小点瘦啊！";
        }else if(bmi<24.0){
            return bmiDTO.getName()+",您好,您的体重指数为:"+bmi+",看样子身材不错！";
        }else if(bmi<27.0){
            return bmiDTO.getName()+",您好,您的体重指数为:"+bmi+",有小点胖啊！";
        }else {
            return bmiDTO.getName()+",您好,您的体重指数为:" +bmi+",超标了啊超标了啊！！";
        }

    }

}
